package com.fly.show;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import com.fly.show.git.GitService;
import com.fly.show.text.TextService;

@Controller
public class IndexController
{
    @Autowired
    GitService gitService;
    
    @Autowired
    TextService textService;
    
    @GetMapping({"/", "/git"})
    public String git(String name, Model model)
    {
        if (StringUtils.isBlank(name))
        {
            model.addAttribute("names", gitService.getSubNames());
        }
        else
        {
            name = StringUtils.trimToEmpty(name);
            model.addAttribute("name", name);
            model.addAttribute("names", gitService.search(name));
        }
        return "git/index";
    }
    
    @GetMapping("/tls")
    public String tls()
    {
        return "tls/index";
    }
}
